package main

import (
	"log"
	"os"
	"sync"
	"time"
)

var Cond = sync.NewCond(&sync.Mutex{})

func main() {

	var m uint64 = 0

	for i := 0; i < 4; i++ {
		go func() {
			for {
				Cond.L.Lock()
				Cond.Wait()
				log.Printf("leenux- %v-%v\n", i, m)
				Cond.L.Unlock()
			}
		}()
	}

	go func() {
		for range time.NewTicker(500 * time.Microsecond).C {
			m++
			Cond.Broadcast()
		}
	}()

	b := make([]byte, 1)
	os.Stdin.Read(b)
}
